<%@ page language="java" contentType= "text/html" pageEncoding="UTF-8"%>
<%@include file="/include/common/griduihead1.jsp"%>
<%@include file="/include/common/griduihead2.jsp"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.jm.web.GridPage" %>
<%@ page import="common.CommonType" %>
<%@ page import="com.jm.web.data.JMForm" %>
<%@ page import="com.jm.utils.Utils" %>
<%@ page import="com.jm.utils.StringHelper" %>
<%@ page import="com.jm.web.form.TableToolbar" %>
<%@ page import="com.jm.web.form.Button" %>
<%@ page import="com.jm.web.form.Empty" %>
<%@ page import="com.jm.web.form.Toolbar" %>
<%
	page1.setMinWidth(450);
	String companyCodeTsn = utils.getsv("companyCodeTsn").toString();
	if(!form.ContainesParam("companyCodeTsn"))
		form.SetParamValue("companyCodeTsn",utils.getsv("companyCodeTsn"));	
		
	companyCodeTsn = form.gpsv("companyCodeTsn");
	
	String whr = "";
	if(!form.isNullOrEmpty("hr003atsn"))
		whr = StringHelper.Format("where tsn in(%1$s)",form.gpsv("hr003atsn"));
	
	String strValue = ","+form.gpsv("value")+",";
	
	TableToolbar toolbar = new TableToolbar();
	toolbar.InitTag(null);
	toolbar.getAddRowButton().setEnab(false);
	toolbar.init();
	toolbar.setLeft(false);
	
	Button calBtn = Toolbar.getNewButton("取消操作","okbtn","okbtn","ax-btn-icon sx-tb-cancel",null);
	calBtn.setWidth("100px");
	calBtn.setOnClick("top.close();");
	Button emptyBtn = Toolbar.getNewButton("清空選擇","okbtn","okbtn","ax-btn-icon sx-tb-restart",null);
	emptyBtn.setWidth("100px");
	emptyBtn.setOnClick("fun_empty();");
	Button okBtn = Toolbar.getNewButton("確定選擇","okbtn","okbtn","ax-btn-icon sx-tb-ok",null);
	okBtn.setWidth("100px");
	okBtn.setOnClick("fun_ok();");
	
	Empty empty = new Empty();
	empty.setWidth("100%");
	toolbar.getItems().clear();
	toolbar.getItems().add(empty);
	toolbar.getItems().add(calBtn);
	toolbar.getItems().add(emptyBtn);
	toolbar.getItems().add(okBtn);
%>
<jm:form>
	<jm:layout postion="north">
		<jm:dp id="dp1" data="<%=Utils.TAG_FORM%>" tabSize="0">
			<jm:tab colModel="200px;*">
				<jm:group captionDisplay="false" hidden="true" colspan="2">
					<input type="hidden" name="hr003atsn" />
					<input type="hidden" name="value" />
				</jm:group>
				<jm:select caption="公司別" captionWidth="40px" utils="<%=utils%>" name="companyCodeTsn" dataSource="info3" sql="<%=StringHelper.Format("select tsn,companyNamech as i18n_companyNamech from hr..hr003a %1$s",whr)%>" onchange="submit();" />
				<jm:field keep="true" captionDisplay="false">
					<%toolbar.onRender(out);%>
				</jm:field>
			</jm:tab>
		</jm:dp>
	</jm:layout>
	<jm:layout postion="center">
<%
	Map map = new HashMap();
	Map mapRole = new HashMap();
	List list = new ArrayList();
	List listOne = new ArrayList();
	List list2 = new ArrayList();
	List list3 = new ArrayList();
	List list4 = new ArrayList();
	List list5 = new ArrayList();
	List list6 = new ArrayList();
	List list7 = new ArrayList();
	List list8 = new ArrayList();
	//List list9 = new ArrayList();
	//List list10 = new ArrayList();
	//List list11 = new ArrayList();
	//List list12 = new ArrayList();
	//List list13 = new ArrayList();
	//List list14 = new ArrayList();
	//List list15 = new ArrayList();
	//List list16 = new ArrayList();
	if("".equals(companyCodeTsn)) {
	out.print("<a style=cursor:pointer; onclick=send('','','');window.close()><font size=1>|---空白</font></a><inpu name='chk' text='' value='' chname='' /><br>");
	} else {
	CommonType commonType = new CommonType(utils);
	map = commonType.role(companyCodeTsn);
	
		mapRole = commonType.orgTitleSn(companyCodeTsn);
	
			list = (List)map.get("0");
			if(list != null) {
				for(int i = 0; i < list.size(); i++) {
				out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list.get(i)).toString())+"','"+list.get(i)+"','"+mapRole.get(list.get(i)).toString()+"');window.close();\"><font size=1>|---"+utils.i18n(mapRole.get(list.get(i)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list.get(i)).toString())+"' value='"+list.get(i)+"' "+(strValue.indexOf(","+list.get(i).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list.get(i)).toString()+"' /><br>");
					listOne = (List)map.get(list.get(i));
				if(listOne != null) {
				for(int j = 0; j < listOne.size(); j++) {
					out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(listOne.get(j)).toString())+"','"+listOne.get(j)+"','"+mapRole.get(listOne.get(j)).toString()+"');window.close();\"><font size=1>　　　|---"+utils.i18n(mapRole.get(listOne.get(j)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(listOne.get(j)).toString())+"' value='"+listOne.get(j)+"' "+(strValue.indexOf(","+listOne.get(j).toString()+",")  >= 0? "checked" : "")+" chname='"+mapRole.get(listOne.get(j)).toString()+"' /><br>");
						list2 = (List)map.get(listOne.get(j));
					if(list2 != null) {
					for(int h = 0; h < list2.size(); h++) {
						out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list2.get(h)).toString())+"','"+list2.get(h)+"','"+mapRole.get(list2.get(h)).toString()+"');window.close();\"><font size=1>　　　　　　|---"+utils.i18n(mapRole.get(list2.get(h)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list2.get(h)).toString())+"' value='"+list2.get(h)+"' "+(strValue.indexOf(","+list2.get(h).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list2.get(h)).toString()+"' /><br>");
							list3 = (List)map.get(list2.get(h));
						if(list3 != null) {
						for(int g = 0; g < list3.size(); g++) {
							out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list3.get(g)).toString())+"','"+list3.get(g)+"','"+mapRole.get(list3.get(g)).toString()+"');window.close();\"><font size=1>　　　　　　　　　|---"+utils.i18n(mapRole.get(list3.get(g)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list3.get(g)).toString())+"' value='"+list3.get(g)+"' "+(strValue.indexOf(","+list3.get(g).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list3.get(g)).toString()+"' /><br>");
								list4 = (List)map.get(list3.get(g));
							if(list4 != null) {
							for(int f = 0; f < list4.size(); f++) {
								out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list4.get(f)).toString())+"','"+list4.get(f)+"','"+mapRole.get(list4.get(f)).toString()+"');window.close();\"><font size=1>　　　　　　　　　　　　|---"+utils.i18n(mapRole.get(list4.get(f)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list4.get(f)).toString())+"' value='"+list4.get(f)+"' "+(strValue.indexOf(","+list4.get(f).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list4.get(f)).toString()+"' /><br>");
									list5 = (List)map.get(list4.get(f));
								if(list5 != null) {
								for(int d = 0; d < list5.size(); d++) {
									out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list5.get(d)).toString())+"','"+list5.get(d)+"','"+mapRole.get(list5.get(d)).toString()+"');window.close();\"><font size=1>　　　　　　　　　　　　　　　|---"+utils.i18n(mapRole.get(list5.get(d)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list5.get(d)).toString())+"' value='"+list5.get(d)+"' "+(strValue.indexOf(","+list5.get(d).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list5.get(d)).toString()+"' /><br>");
										list6 = (List)map.get(list5.get(d));
									if(list6 != null) {
									for(int s = 0; s < list6.size(); s++) {
										out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list6.get(s)).toString())+"','"+list6.get(s)+"','"+mapRole.get(list6.get(s)).toString()+"');window.close();\"><font size=1>　　　　　　　　　　　　　　　　　　|---"+utils.i18n(mapRole.get(list6.get(s)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list6.get(s)).toString())+"' value='"+list6.get(s)+"' "+(strValue.indexOf(","+list6.get(s).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list6.get(s)).toString()+"' /><br>");
											list7 = (List)map.get(list6.get(s));
											if(list7 != null) {
											for(int a = 0; a < list7.size(); a++) {
												out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list7.get(a)).toString())+"','"+list7.get(a)+"','"+mapRole.get(list7.get(a)).toString()+"');window.close();\"><font size=1>　　　　　　　　　　　　　　　　　　　　　|---"+utils.i18n(mapRole.get(list7.get(s)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list7.get(a)).toString())+"' value='"+list7.get(a)+"' "+(strValue.indexOf(","+list7.get(a).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list7.get(a)).toString()+"' /><br>");
													list8 = (List)map.get(list7.get(a));
													if(list8 != null) {
													for(int q = 0; q < list8.size(); q++) {
														out.println("<a style=cursor:pointer; onclick=\"send('"+utils.i18n(mapRole.get(list8.get(q)).toString())+"','"+list8.get(q)+"','"+mapRole.get(list8.get(q)).toString()+"');window.close();\"><font size=1>　　　　　　　　　　　　　　　　　　　　　　　　|---"+utils.i18n(mapRole.get(list8.get(s)).toString())+"</font></a><input type='checkbox' name='chk' text='"+utils.i18n(mapRole.get(list8.get(q)).toString())+"' value='"+list8.get(q)+"' "+(strValue.indexOf(","+list8.get(q).toString()+",") >= 0 ? "checked" : "")+" chname='"+mapRole.get(list8.get(q)).toString()+"' /><br>");
													}
													}
											}
											}
									}
									}
								}
								}	
							}
							}	
						}
						}
					}
					}
				}
				}
			}
			}
			out.println();
	}
%>
	</jm:layout>
</jm:form>
<jm:script><script type="text/javascript" charset="UTF-8">
	var config = top.dialogArguments;
	top.returnValue = {}; 
	
	function fun_empty(){
		top.returnValue['action'] = 'clear';
		top.returnValue.ret = 'ok';
		top.close();
	}
	
	function fun_ok(){
		top.returnValue['action'] = 'set';
		top.returnValue.ret = 'ok';
		var hr003aoption = $('select[name=companyCodeTsn] option:selected');
		
		var text = '';
		var value = '';
		var chname = '';
		$('input[name=chk]:checked').each(function(){
			if(text != '')
				text += ',';
			text += $(this).gv('text');
			
			if(value != '')
				value += ',';
			value += $(this).gv('value');
			
			if(chname != '')
				chname += ',';
			chname += $(this).gv('chname');
		});
		
		top.returnValue.text = text;
		top.returnValue.value = value;
		top.returnValue.chname = chname;
		
		top.returnValue.hr003atsn = hr003aoption.val();
		top.returnValue.hr003aname = hr003aoption.text();
		top.close();
	}
	
	function send(val,tsn,chname) { 
		return ;
	}
</script></jm:script>
<%@include file="/include/common/griduiend.jsp"%>
